////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2012 Kentaro Sekimoto  All rights reserved.
////////////////////////////////////////////////////////////////////////////

#ifndef PHY_H_
#define PHY_H_

/* LAN8187C PHY Registers */
#define PHY_REG_BMCR    0x00    // Basic Mode Control Register
#define PHY_REG_BMSR    0x01    // Basic Mode Status Register
#define PHY_REG_IDR1    0x02    // PHY Identifier 1
#define PHY_REG_IDR2    0x03    // PHY Identifier 2
#define PHY_REG_STS     0x10    // Status Register
#define PHY_REG_19      19      // Extended Control Register 19
#define PHY_REG_LEDC    20
#define PHY_REG_INTC    22

#define BMCR_RESET      0x8000
#define BMSR_AUTO_DONE  0x0020

//#define PHY_AUTO_NEG  0x1000    // Select Auto Negotiation
#define PHY_AUTO_NEG    0x1200      // Select Auto Negotiation

#define STS_LINK_ON     0x1
#define STS_10_MBIT     0x2
#define STS_FULL_DUP    0x4

#define MII_WR_TOUT     0x010000    // MII Write timeout count
#define MII_RD_TOUT     0x010000    // MII Read timeout count

#define ICS1894_ADDR    0x10        // PHY device address for Wakamatsu FM3 LAN board
#define LAN8187_ADDR    0x06        // PHY device address for Wakamatsu ARM LAN board
#define DP83848_ADDR    0x01        // PHY device address for DP83848
#define LAN8700_ADDR    0x1F        // PHY device address for Will Electronics WX-PHY
#define ICS1894_ID      0x0015f450  // PHY Identifier of ICS1894
#define LAN8187_ID      0x0006C0C4  // PHY Identifier of LAN8187
#define DP83848_ID      0x20005C90  // PHY Identifier of DP83848
#define LAN8700_ID      0x0007C0C0  // PHY Identifier of LAN8700i
#define PHY_ADDR        ICS1894_ADDR
#define DEF_PHY_RESET_RETRY     3
#define DEF_PHY_AUTONEG_RETRY   1
#define DEF_PHY_RESET_STATUS_RETRY      10000
#define DEF_PHY_AUTONEG_STATUS_RETRY    100000

#endif /* PHY_H_ */
